let ChatPeopleModel = require('../model').chatPeopleModel;
exports.createChatPeople = function (conn,params) {
    return new Promise(function (resolve, reject) {
        let sql = "insert into chat_people(??) values ?;";
        conn.query(sql, [ChatPeopleModel.batchInsertProp,params], function (err, result) {
            printLog("=createChatPeople=", this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};

exports.updateChatPeople = function (conn,params) {
    return new Promise(function (resolve, reject) {
        let sql = "update chat_people set ? where ChatNo=? and openid =?;";
        conn.query(sql, [params.updateObj,params.ChatNo,params.openid], function (err, result) {
            printLog("=createChatPeople=", this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};
exports.hasSeen = function (conn,params) {
    return new Promise(function (resolve, reject) {
        let sql = "update chat_people set NewMsg='F' where ChatNo=? and openid !=?;";
        conn.query(sql, [params.ChatNo,params.openid], function (err, result) {
            printLog("=hasSeen=", this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};